<?php

namespace App\Store\Controllers\Goods;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Common\Services\Store\Common as StoreCommon;


use App\Common\Services\CommonExcelExport;
use App\Store\Models\Account\SiteStore;
use App\Store\Models\Basic\GoodsBrand;
use App\Store\Models\Basic\GoodsCategory;
use App\Store\Models\Basic\GoodsCraft;
use App\Store\Models\Basic\GoodsPricetype;
use App\Store\Models\Basic\GoodsStone;
use App\Store\Models\Basic\GoodsStyle;
use App\Store\Models\Basic\PaytypeList;
use App\Store\Models\Basic\Supply;
use App\Store\Models\Goods\GoodsChangeLog;
use Maatwebsite\Excel\Facades\Excel;

/**
 * 商品修改记录
 */
class GoodsChangeLogController extends Controller
{
    /**
     * 商品修改列表
     */
    public function getlist(Request $request){

        $list = GoodsChangeLog::getList($request);
        return response()->json(['code' => '000', 'msg' => '获取成功', 'data' => $list]);
    }

    /**
     * 商品修改详情
     */
    public function getinfo(Request $request){
        $cp_id = StoreCommon::getCurrentAccountCompanyId($request);
        $list = GoodsChangeLog::getinfo($request);

        $goodstylelist = GoodsStyle::where(['cp_id' => $cp_id])->pluck('style_name','id')->toArray();
        $goodscategorylist = GoodsCategory::where(['cp_id' => $cp_id])->pluck('category_name','id')->toArray();
        $goodscraftlist = GoodsCraft::where(['cp_id' => $cp_id])->pluck('craft_name','id')->toArray();
        $goodsbrandlist = GoodsBrand::where(['cp_id' => $cp_id])->pluck('brand_name','id')->toArray();
        $goodspricetypelist = GoodsPricetype::where(['cp_id' => $cp_id])->pluck('pricetype_name','id')->toArray();
        $goodsstonelist = GoodsStone::where(['cp_id' => $cp_id])->pluck('stone_name','id')->toArray();



        foreach($list['list'] as &$info){
            $info['beforedata']=json_decode($info['beforedata'],true);
            $info['afterdata']=json_decode($info['afterdata'],true);
            $beforedata =$info['beforedata'];
            $afterdata =$info['afterdata'];

            $info['beforedata']['category_name']=isset($goodscategorylist[$beforedata['goods_category_id']])?$goodscategorylist[$beforedata['goods_category_id']]:'';
            $info['beforedata']['goods_craft_name']=(isset($beforedata['goods_craft_id'])&&$beforedata['goods_craft_id']>0)?($goodscraftlist[$beforedata['goods_craft_id']]?? ''):'';
            $info['beforedata']['goods_stone_name']=(isset($beforedata['goods_stone_id'])&&$beforedata['goods_stone_id']>0)?$goodsstonelist[$beforedata['goods_stone_id']]:'';
            $info['beforedata']['style_name']=(isset($beforedata['goods_style_id'])&&$beforedata['goods_style_id']>0)?$goodstylelist[$beforedata['goods_style_id']]:'';
            $info['beforedata']['brand_name']=(isset($beforedata['goods_brand_id'])&&$beforedata['goods_brand_id']>0)?$goodsbrandlist[$beforedata['goods_brand_id']]:'';
            $info['beforedata']['goods_pricetype_name']=(isset($beforedata['goods_pricetype_id'])&&$beforedata['goods_pricetype_id']>0)?$goodspricetypelist[$beforedata['goods_pricetype_id']]:'';


            $info['afterdata']['category_name']=isset($goodscategorylist[$afterdata['goods_category_id']])?$goodscategorylist[$afterdata['goods_category_id']]:'';
            $info['afterdata']['goods_craft_name']=(isset($afterdata['goods_craft_id'])&&$afterdata['goods_craft_id']>0)?($goodscraftlist[$afterdata['goods_craft_id']]?? ''):'';
            $info['afterdata']['goods_stone_name']=(isset($afterdata['goods_stone_id'])&&$afterdata['goods_stone_id']>0)?$goodsstonelist[$afterdata['goods_stone_id']]:'';
            $info['afterdata']['style_name']=(isset($afterdata['goods_style_id'])&&$afterdata['goods_style_id']>0)?$goodstylelist[$afterdata['goods_style_id']]:'';
            $info['afterdata']['brand_name']=(isset($afterdata['goods_brand_id'])&&$afterdata['goods_brand_id']>0)?$goodsbrandlist[$afterdata['goods_brand_id']]:'';
            $info['afterdata']['goods_pricetype_name']=(isset($afterdata['goods_pricetype_id'])&&$afterdata['goods_pricetype_id']>0)?$goodspricetypelist[$afterdata['goods_pricetype_id']]:'';

        }


        return response()->json(['code' => '000', 'msg' => '获取成功', 'data' => $list]);
    }

    /**
     * 导出
     */
    public function doexport(Request $request){
        $list = GoodsChangeLog::getList($request)['list'];
        $row = [

            ['order_sncode'=>'商品修改记录列表'],
            [
            'order_sncode'=>'修改单编号',
            'create_account_real_name'=>'修改人',
            'create_at'=>'修改时间',
            'startstore'=>'初始入库门店',
            'targetstore'=>'目标门店',
            'beforedata.goods_sn_code'=>'前：商品条码',
            'afterdata.goods_sn_code'=>'后：商品条码',
            'beforedata.goods_name'=>'前：品名',
            'afterdata.goods_name'=>'后：品名',
            'beforedata.category_name'=>'前：商品类别',
            'afterdata.category_name'=>'后：商品类别',
            'beforedata.weight'=>'前：重量',
            'afterdata.weight'=>'后：重量',
            'beforedata.netglod_weight'=>'前：金重',
            'afterdata.netglod_weight'=>'后：金重',
            'beforedata.label_price'=>'前：标签价',
            'afterdata.label_price'=>'后：标签价',
            'beforedata.content'=>'前：含量',
            'afterdata.content'=>'后：含量',
            'beforedata.goods_craft_name'=>'前：工艺',
            'afterdata.goods_craft_name'=>'后：工艺',
            'beforedata.goods_stone_name'=>'前：石料材质',
            'afterdata.goods_stone_name'=>'后：石料材质',
            'beforedata.style_name'=>'前：款式',
            'afterdata.style_name'=>'后：款式',
            'beforedata.count'=>'前：数量',
            'afterdata.count'=>'后：数量',
            'beforedata.total_weight'=>'前：总重量',
            'afterdata.total_weight'=>'后：总重量',
            'beforedata.cf_no'=>'前：证书号',
            'afterdata.cf_no'=>'后：证书号',
            'beforedata.cf_no_gia'=>'前：GIA证书号',
            'afterdata.cf_no_gia'=>'后：GIA证书号',
            'beforedata.main_stone_weigth'=>'前：主石重',
            'afterdata.main_stone_weigth'=>'后：主石重',
            'beforedata.main_stone_count'=>'前：主石数',
            'afterdata.main_stone_count'=>'后：主石数',
            'beforedata.other_stone_weigth'=>'前：副石重',
            'afterdata.other_stone_weigth'=>'后：副石重',
            'beforedata.other_stone_count'=>'前：副石数',
            'afterdata.other_stone_count'=>'后：副石数',
            'beforedata.c_no'=>'前：圈号',
            'afterdata.c_no'=>'后：圈号',
            'beforedata.costpiece_fee'=>'前：件成本工费',
            'afterdata.costpiece_fee'=>'后：件成本工费',
            'beforedata.costgram_fee'=>'前：克成本工费',
            'afterdata.costgram_fee'=>'后：克成本工费',
            'beforedata.costglod_price'=>'前：金价',
            'afterdata.costglod_price'=>'后：金价',
            //成本工费--不清楚
            'beforedata.piececost_fee'=>'前：单件成本',
            'afterdata.piececost_fee'=>'后：单件成本',
            'beforedata.total_fee'=>'前：总成本',
            'afterdata.total_fee'=>'后：总成本',
            'beforedata.brand_name'=>'前：品牌',
            'afterdata.brand_name'=>'后：品牌',
            'beforedata.color'=>'前：颜色',
            'afterdata.color'=>'后：颜色',
            'beforedata.clarity'=>'前：净度',
            'afterdata.clarity'=>'后：净度',
            'beforedata.goods_pricetype_name'=>'前：价格类型',
            'afterdata.goods_pricetype_name'=>'后：价格类型',
        ]];
        $cp_id = StoreCommon::getCurrentAccountCompanyId($request);
        $supplylist = Supply::where(['cp_id' => $cp_id])->pluck('supply_name','id')->toArray();
        $goodstylelist = GoodsStyle::where(['cp_id' => $cp_id])->pluck('style_name','id')->toArray();
        $goodscategorylist = GoodsCategory::where(['cp_id' => $cp_id])->pluck('category_name','id')->toArray();
        $goodscraftlist = GoodsCraft::where(['cp_id' => $cp_id])->pluck('craft_name','id')->toArray();
        $goodsbrandlist = GoodsBrand::where(['cp_id' => $cp_id])->pluck('brand_name','id')->toArray();
        $goodspricetypelist = GoodsPricetype::where(['cp_id' => $cp_id])->pluck('pricetype_name','id')->toArray();
        $goodsstonelist = GoodsStone::where(['cp_id' => $cp_id])->pluck('stone_name','id')->toArray();
        $paytypelist = PaytypeList::where(['cp_id' => $cp_id])->pluck('paytype_name','id')->toArray();

        $is_store_account = StoreCommon::getIsStoreAccount($request);
        if (!$is_store_account) {
            unset($row[0]['beforedata.costglod_price']);
            unset($row[0]['afterdata.costglod_price']);
            unset($row[0]['beforedata.total_fee']);
            unset($row[0]['afterdata.total_fee']);
        }

        $exceldata = [];
        foreach ($list as $val) {
            $val['beforedata']=json_decode($val['beforedata'],true);
            $val['afterdata']=json_decode($val['afterdata'],true);
            $exceldata[] = [
            'order_sncode'=>$val['order_sncode'],
            'create_account_real_name'=>$val['create_account_real_name'],
            'create_at'=>date('Y-m-d H:i:s',$val['create_at']),
            'startstore'=>isset($val['start_store_info']['store_name'])?$val['start_store_info']['store_name']:'',
            'targetstore'=>isset($val['storeinfo']['store_name'])?$val['storeinfo']['store_name']:'',
            'beforedata.goods_sn_code'=>$val['beforedata']['goods_sn_code'],
            'afterdata.goods_sn_code'=>$val['afterdata']['goods_sn_code'],
            'beforedata.goods_name'=>$val['beforedata']['goods_name'],
            'afterdata.goods_name'=>$val['afterdata']['goods_name'],
            'beforedata.category_name'=>isset($goodscategorylist[$val['beforedata']['goods_category_id']])?$goodscategorylist[$val['beforedata']['goods_category_id']]:'',
            'afterdata.category_name'=>isset($goodscategorylist[$val['afterdata']['goods_category_id']])?$goodscategorylist[$val['afterdata']['goods_category_id']]:'',
            'beforedata.weight'=>$val['beforedata']['piece_weight'],
            'afterdata.weight'=>$val['afterdata']['piece_weight'],
            'beforedata.netglod_weight'=>$val['beforedata']['netglod_weight'],
            'afterdata.netglod_weight'=>$val['afterdata']['netglod_weight'],
            'beforedata.label_price'=>$val['beforedata']['label_price']/100,
            'afterdata.label_price'=>$val['afterdata']['label_price']/100,
            'beforedata.content'=>$val['beforedata']['content']?? '',
            'afterdata.content'=>$val['afterdata']['content']??'',
            'beforedata.goods_craft_name'=>isset($goodscraftlist[$val['beforedata']['goods_craft_id']])?$goodscraftlist[$val['beforedata']['goods_craft_id']]:'',
            'afterdata.goods_craft_name'=>isset($goodscraftlist[$val['afterdata']['goods_craft_id']])?$goodscraftlist[$val['afterdata']['goods_craft_id']]:'',
            'beforedata.goods_stone_name'=>isset($goodsstonelist[$val['beforedata']['goods_stone_id']])?$goodsstonelist[$val['beforedata']['goods_stone_id']]:'',
            'afterdata.goods_stone_name'=>isset($goodsstonelist[$val['afterdata']['goods_stone_id']])?$goodsstonelist[$val['afterdata']['goods_stone_id']]:'',
            'beforedata.style_name'=>isset($goodstylelist[$val['beforedata']['goods_style_id']])?$goodstylelist[$val['beforedata']['goods_style_id']]:'',
            'afterdata.style_name'=>isset($goodstylelist[$val['afterdata']['goods_style_id']])?$goodstylelist[$val['afterdata']['goods_style_id']]:'',
            'beforedata.count'=>$val['beforedata']['count'],
            'afterdata.count'=>$val['afterdata']['count'],
            'beforedata.total_weight'=>$val['beforedata']['piece_weight']*$val['beforedata']['count'],
            'afterdata.total_weight'=>$val['afterdata']['piece_weight']*$val['afterdata']['count'],
            'beforedata.cf_no'=>$val['beforedata']['cf_no'],
            'afterdata.cf_no'=>$val['afterdata']['cf_no'],
            'beforedata.cf_no_gia'=>$val['beforedata']['cf_no_gia'],
            'afterdata.cf_no_gia'=>$val['afterdata']['cf_no_gia'],
            'beforedata.main_stone_weigth'=>$val['beforedata']['main_stone_weigth'],
            'afterdata.main_stone_weigth'=>$val['afterdata']['main_stone_weigth'],
            'beforedata.main_stone_count'=>$val['beforedata']['main_stone_count'],
            'afterdata.main_stone_count'=>$val['afterdata']['main_stone_count'],
            'beforedata.other_stone_weigth'=>$val['beforedata']['other_stone_weigth'],
            'afterdata.other_stone_weigth'=>$val['afterdata']['other_stone_weigth'],
            'beforedata.other_stone_count'=>$val['beforedata']['other_stone_count'],
            'afterdata.other_stone_count'=>$val['afterdata']['other_stone_count'],
            'beforedata.c_no'=>$val['beforedata']['c_no'],
            'afterdata.c_no'=>$val['afterdata']['c_no'],
            'beforedata.costpiece_fee'=>$val['beforedata']['costpiece_fee']/100,
            'afterdata.costpiece_fee'=>$val['afterdata']['costpiece_fee']/100,
            'beforedata.costgram_fee'=>$val['beforedata']['costgram_fee']/100,
            'afterdata.costgram_fee'=>$val['afterdata']['costgram_fee']/100,
            'beforedata.costglod_price'=>$val['beforedata']['costglod_price']/100,
            'afterdata.costglod_price'=>$val['afterdata']['costglod_price']/100,
            //成本工费--不清楚
            'beforedata.piececost_fee'=>$val['beforedata']['piececost_fee']/100,
            'afterdata.piececost_fee'=>$val['afterdata']['piececost_fee']/100,
            'beforedata.total_fee'=>$val['beforedata']['piececost_fee']*$val['beforedata']['count']/100,
            'afterdata.total_fee'=>$val['afterdata']['piececost_fee']*$val['afterdata']['count']/100,
            'beforedata.brand_name'=>isset($goodsbrandlist[$val['beforedata']['goods_brand_id']])?$goodsbrandlist[$val['beforedata']['goods_brand_id']]:'',
            'afterdata.brand_name'=>isset($goodsbrandlist[$val['afterdata']['goods_brand_id']])?$goodsbrandlist[$val['afterdata']['goods_brand_id']]:'',
            'beforedata.color'=>$val['beforedata']['color'],
            'afterdata.color'=>$val['afterdata']['color'],
            'beforedata.clarity'=>$val['beforedata']['clarity'],
            'afterdata.clarity'=>$val['afterdata']['clarity'],
            'beforedata.goods_pricetype_name'=>isset($goodspricetypelist[$val['beforedata']['goods_pricetype_id']])?$goodspricetypelist[$val['beforedata']['goods_pricetype_id']]:'',
            'afterdata.goods_pricetype_name'=>isset($goodspricetypelist[$val['afterdata']['goods_pricetype_id']])?$goodspricetypelist[$val['afterdata']['goods_pricetype_id']]:'',
            ];


        }
        $filename = '商品修改记录导出_' . time() . '.xlsx';
        return Excel::download(new CommonExcelExport($row, $exceldata), $filename);

    }



    public function doexportbyinfo(Request $request){
        $list = GoodsChangeLog::getinfo($request)['list'];
        $row = [
            ['order_sncode'=>'商品修改记录列表'],
            [
            'order_sncode'=>'修改单编号',
            'create_account_real_name'=>'修改人',
            'create_at'=>'修改时间',
            'startstore'=>'初始入库门店',
            'targetstore'=>'目标门店',
            'beforedata.goods_sn_code'=>'前：商品条码',
            'afterdata.goods_sn_code'=>'后：商品条码',
            'beforedata.goods_name'=>'前：品名',
            'afterdata.goods_name'=>'后：品名',
            'beforedata.category_name'=>'前：商品类别',
            'afterdata.category_name'=>'后：商品类别',
            'beforedata.weight'=>'前：重量',
            'afterdata.weight'=>'后：重量',
            'beforedata.netglod_weight'=>'前：金重',
            'afterdata.netglod_weight'=>'后：金重',
            'beforedata.label_price'=>'前：标签价',
            'afterdata.label_price'=>'后：标签价',
            'beforedata.content'=>'前：含量',
            'afterdata.content'=>'后：含量',
            'beforedata.goods_craft_name'=>'前：工艺',
            'afterdata.goods_craft_name'=>'后：工艺',
            'beforedata.goods_stone_name'=>'前：石料材质',
            'afterdata.goods_stone_name'=>'后：石料材质',
            'beforedata.style_name'=>'前：款式',
            'afterdata.style_name'=>'后：款式',
            'beforedata.count'=>'前：数量',
            'afterdata.count'=>'后：数量',
            'beforedata.total_weight'=>'前：总重量',
            'afterdata.total_weight'=>'后：总重量',
            'beforedata.cf_no'=>'前：证书号',
            'afterdata.cf_no'=>'后：证书号',
            'beforedata.cf_no_gia'=>'前：GIA证书号',
            'afterdata.cf_no_gia'=>'后：GIA证书号',
            'beforedata.main_stone_weigth'=>'前：主石重',
            'afterdata.main_stone_weigth'=>'后：主石重',
            'beforedata.main_stone_count'=>'前：主石数',
            'afterdata.main_stone_count'=>'后：主石数',
            'beforedata.other_stone_weigth'=>'前：副石重',
            'afterdata.other_stone_weigth'=>'后：副石重',
            'beforedata.other_stone_count'=>'前：副石数',
            'afterdata.other_stone_count'=>'后：副石数',
            'beforedata.c_no'=>'前：圈号',
            'afterdata.c_no'=>'后：圈号',
            'beforedata.costpiece_fee'=>'前：件成本工费',
            'afterdata.costpiece_fee'=>'后：件成本工费',
            'beforedata.costgram_fee'=>'前：克成本工费',
            'afterdata.costgram_fee'=>'后：克成本工费',
            'beforedata.costglod_price'=>'前：金价',
            'afterdata.costglod_price'=>'后：金价',
            //成本工费--不清楚
            'beforedata.piececost_fee'=>'前：单件成本',
            'afterdata.piececost_fee'=>'后：单件成本',
            'beforedata.total_fee'=>'前：总成本',
            'afterdata.total_fee'=>'后：总成本',
            'beforedata.brand_name'=>'前：品牌',
            'afterdata.brand_name'=>'后：品牌',
            'beforedata.color'=>'前：颜色',
            'afterdata.color'=>'后：颜色',
            'beforedata.clarity'=>'前：净度',
            'afterdata.clarity'=>'后：净度',
            'beforedata.goods_pricetype_name'=>'前：价格类型',
            'afterdata.goods_pricetype_name'=>'后：价格类型',
        ]];
        $cp_id = StoreCommon::getCurrentAccountCompanyId($request);
        $supplylist = Supply::where(['cp_id' => $cp_id])->pluck('supply_name','id')->toArray();
        $goodstylelist = GoodsStyle::where(['cp_id' => $cp_id])->pluck('style_name','id')->toArray();
        $goodscategorylist = GoodsCategory::where(['cp_id' => $cp_id])->pluck('category_name','id')->toArray();
        $goodscraftlist = GoodsCraft::where(['cp_id' => $cp_id])->pluck('craft_name','id')->toArray();
        $goodsbrandlist = GoodsBrand::where(['cp_id' => $cp_id])->pluck('brand_name','id')->toArray();
        $goodspricetypelist = GoodsPricetype::where(['cp_id' => $cp_id])->pluck('pricetype_name','id')->toArray();
        $goodsstonelist = GoodsStone::where(['cp_id' => $cp_id])->pluck('stone_name','id')->toArray();
        $paytypelist = PaytypeList::where(['cp_id' => $cp_id])->pluck('paytype_name','id')->toArray();


        $exceldata = [];
        foreach ($list as $val) {
            $val['beforedata']=json_decode($val['beforedata'],true);
            $val['afterdata']=json_decode($val['afterdata'],true);
            $exceldata[] = [
            'order_sncode'=>$val['order_sncode'],
            'create_account_real_name'=>$val['create_account_real_name'],
            'create_at'=>date('Y-m-d H:i:s',$val['create_at']),
            'startstore'=>isset($val['start_store_info']['store_name'])?$val['start_store_info']['store_name']:'',
            'targetstore'=>isset($val['storeinfo']['store_name'])?$val['storeinfo']['store_name']:'',
            'beforedata.goods_sn_code'=>$val['beforedata']['goods_sn_code'],
            'afterdata.goods_sn_code'=>$val['afterdata']['goods_sn_code'],
            'beforedata.goods_name'=>$val['beforedata']['goods_name'],
            'afterdata.goods_name'=>$val['afterdata']['goods_name'],
            'beforedata.category_name'=>isset($goodscategorylist[$val['beforedata']['goods_category_id']])?$goodscategorylist[$val['beforedata']['goods_category_id']]:'',
            'afterdata.category_name'=>isset($goodscategorylist[$val['afterdata']['goods_category_id']])?$goodscategorylist[$val['afterdata']['goods_category_id']]:'',
            'beforedata.weight'=>$val['beforedata']['piece_weight'],
            'afterdata.weight'=>$val['afterdata']['piece_weight'],
            'beforedata.netglod_weight'=>$val['beforedata']['netglod_weight'],
            'afterdata.netglod_weight'=>$val['afterdata']['netglod_weight'],
            'beforedata.label_price'=>$val['beforedata']['label_price']/100,
            'afterdata.label_price'=>$val['afterdata']['label_price']/100,
            'beforedata.content'=>$val['beforedata']['content'],
            'afterdata.content'=>$val['afterdata']['content'],
            'beforedata.goods_craft_name'=>isset($goodscraftlist[$val['beforedata']['goods_craft_id']])?$goodscraftlist[$val['beforedata']['goods_craft_id']]:'',
            'afterdata.goods_craft_name'=>isset($goodscraftlist[$val['afterdata']['goods_craft_id']])?$goodscraftlist[$val['afterdata']['goods_craft_id']]:'',
            'beforedata.goods_stone_name'=>isset($goodsstonelist[$val['beforedata']['goods_stone_id']])?$goodsstonelist[$val['beforedata']['goods_stone_id']]:'',
            'afterdata.goods_stone_name'=>isset($goodsstonelist[$val['afterdata']['goods_stone_id']])?$goodsstonelist[$val['afterdata']['goods_stone_id']]:'',
            'beforedata.style_name'=>isset($goodstylelist[$val['beforedata']['goods_style_id']])?$goodstylelist[$val['beforedata']['goods_style_id']]:'',
            'afterdata.style_name'=>isset($goodstylelist[$val['afterdata']['goods_style_id']])?$goodstylelist[$val['afterdata']['goods_style_id']]:'',
            'beforedata.count'=>$val['beforedata']['count'],
            'afterdata.count'=>$val['afterdata']['count'],
            'beforedata.total_weight'=>$val['beforedata']['piece_weight']*$val['beforedata']['count'],
            'afterdata.total_weight'=>$val['afterdata']['piece_weight']*$val['afterdata']['count'],
            'beforedata.cf_no'=>$val['beforedata']['cf_no'],
            'afterdata.cf_no'=>$val['afterdata']['cf_no'],
            'beforedata.cf_no_gia'=>$val['beforedata']['cf_no_gia'],
            'afterdata.cf_no_gia'=>$val['afterdata']['cf_no_gia'],
            'beforedata.main_stone_weigth'=>$val['beforedata']['main_stone_weigth'],
            'afterdata.main_stone_weigth'=>$val['afterdata']['main_stone_weigth'],
            'beforedata.main_stone_count'=>$val['beforedata']['main_stone_count'],
            'afterdata.main_stone_count'=>$val['afterdata']['main_stone_count'],
            'beforedata.other_stone_weigth'=>$val['beforedata']['other_stone_weigth'],
            'afterdata.other_stone_weigth'=>$val['afterdata']['other_stone_weigth'],
            'beforedata.other_stone_count'=>$val['beforedata']['other_stone_count'],
            'afterdata.other_stone_count'=>$val['afterdata']['other_stone_count'],
            'beforedata.c_no'=>$val['beforedata']['c_no'],
            'afterdata.c_no'=>$val['afterdata']['c_no'],
            'beforedata.costpiece_fee'=>$val['beforedata']['costpiece_fee']/100,
            'afterdata.costpiece_fee'=>$val['afterdata']['costpiece_fee']/100,
            'beforedata.costgram_fee'=>$val['beforedata']['costgram_fee']/100,
            'afterdata.costgram_fee'=>$val['afterdata']['costgram_fee']/100,
            'beforedata.costglod_price'=>$val['beforedata']['costglod_price']/100,
            'afterdata.costglod_price'=>$val['afterdata']['costglod_price']/100,
            //成本工费--不清楚
            'beforedata.piececost_fee'=>$val['beforedata']['piececost_fee']/100,
            'afterdata.piececost_fee'=>$val['afterdata']['piececost_fee']/100,
            'beforedata.total_fee'=>$val['beforedata']['piececost_fee']*$val['beforedata']['count']/100,
            'afterdata.total_fee'=>$val['afterdata']['piececost_fee']*$val['afterdata']['count']/100,
            'beforedata.brand_name'=>isset($goodsbrandlist[$val['beforedata']['goods_brand_id']])?$goodsbrandlist[$val['beforedata']['goods_brand_id']]:'',
            'afterdata.brand_name'=>isset($goodsbrandlist[$val['afterdata']['goods_brand_id']])?$goodsbrandlist[$val['afterdata']['goods_brand_id']]:'',
            'beforedata.color'=>$val['beforedata']['color'],
            'afterdata.color'=>$val['afterdata']['color'],
            'beforedata.clarity'=>$val['beforedata']['clarity'],
            'afterdata.clarity'=>$val['afterdata']['clarity'],
            'beforedata.goods_pricetype_name'=>isset($goodspricetypelist[$val['beforedata']['goods_pricetype_id']])?$goodspricetypelist[$val['beforedata']['goods_pricetype_id']]:'',
            'afterdata.goods_pricetype_name'=>isset($goodspricetypelist[$val['afterdata']['goods_pricetype_id']])?$goodspricetypelist[$val['afterdata']['goods_pricetype_id']]:'',
            ];


        }
        $filename = '商品修改记录导出_' . time() . '.xlsx';
        //导出改到此处，2024-10-22 16：10
        return Excel::download(new CommonExcelExport($row, $exceldata), $filename);

    }

}
